using System;

namespace DeflateLib
{
    /// <summary>
    /// Shifting (queue-like) data array.
    /// </summary>
	sealed class LZ77Window
	{
		int size;
		byte[] data;
		int position;
		
		public byte[] Data
		{
			get { return data; }
		}
		
		public int Size
		{
			get { return size; }
		}		
		
		public int Position
		{
			get { return position; }
		}
		
		public LZ77Window(int size)
		{
			this.size = size;
			this.data = new byte[size];
			this.position = 0;
		}

		public void AppendData(byte[] buffer, int offset, int length)
		{
			Array.Copy(buffer, offset, data, position, length);
			position += length;
		}
		
		public void Shift(int length)
		{
            Array.Copy(data, length, data, 0, Position - length);
			position -= length;
		}

        public void Clear()
        {
            this.position = 0;
        }
	}
}